Load balancing across multiple application instances optimizes resource utilization
http {
upstream myapp1 {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80;
location / {
proxy_pass http://myapp1;
}
}
}
least_conn directive at the top of the upstream blockip_hash directive in the upstream group configuration applies the ip hash algorithmweight= is a directive (optional parameter of the server directive), increases likelihood of matching in load balancing (default weight=1)Reverse proxy implementation in nginx includes in-band server health checks
max_fail directive (for server) sets number of consecutive unsuccessful attempts during fail_timeout (default 1)